<template>
	<view class="content">
		<view class="top">
			<view class="list">
				<text>装货地：{{info.beg_land}}</text>
			</view>
			<view class="list">
				<text>卸货地：{{info.consignee_address}}</text>
			</view>
			<view class="list">
				<text>预计装货时间：{{info.plan_beg_date}}</text>
			</view>
			<view class="list">
				<text>预计到货时间：{{info.plan_end_date}}</text>
			</view>
		</view>
		<view class="item">
			<view class="code">
				<text>货物信息</text>
			</view>
			<view class="goodslist">
				<text class="name">商品名称</text>
				<text class="name">商品数量</text>
				<text class="name">单位</text>
				<text class="name">商品单价</text>
			</view>
			<view class="goodslist">
				<text class="name">{{info.goods_name}}</text>
				<text class="name">{{info.goods_num}}</text>
				<text class="name">{{info.sku_name}}</text>
				<text class="name">{{info.goods_price}}</text>
			</view>
		</view>
		<view class="orderInfo">
			<view class="list">
				<text>指派司机</text>
				<text>{{info.driver}}</text>
			</view>
			<view class="list">
				<text>收货人电话</text>
				<text>{{info.consignee_phone}}</text>
			</view>
			<view class="list">
				<text>选择商品</text>
				<text>{{info.goods_name}}</text>
			</view>
			<view class="list">
				<text>运费单价</text>
				<input type="text" placeholder="请输入" placeholder-class="input-style" class="ipt" v-model="info.freight"/>
			</view>
			<view class="list" >
				<text>运费总价</text>
				<view class="sum">{{(info.Totalamount = (info.freight*info.goods_num))}}</view>
			</view>
			<view class="list" style="justify-content: flex-end;">
				<text>操作员：{{info.prepared_by}}</text>
			</view>
			<!-- <view class="list" >
				<text>截止接单时间</text>
				<text>{{info.end}}</text>
			</view> -->
		</view>
		<view class="btnbox">
			<view class="btn next" hover-class="none" @tap="submit">提交</view>
			<navigator class="btn" open-type="navigateBack" hover-class="none">返回</navigator>
		</view>
	</view>
</template>

<script setup>
	import {
		placeOrder
	} from '../../network/order.js';
	import {
		ref,
		reactive
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';
	onLoad((res) => {
		Object.assign(info, JSON.parse(res.info))
		info.freight = ''
	})
	const info = reactive({})
	const submit = () => {
		if(!info.freight){
			uni.showToast({
				title: "请输入运费单价"
			})
			return
		}
		placeOrder(info).then(res => {
			uni.showToast({
				title: "提交成功"
			})
			setTimeout(()=>{
				uni.switchTab({
					url:'../order/order'
				})
			},300)
		})
	}
</script>

<style lang="scss">
	.top {
		margin-top: 2rpx;
		background-color: #fff;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		font-size: 28rpx;

		.list {
			display: flex;
			justify-content: space-between;
			padding: 10rpx 0;
		}
	}

	.item {
		margin: 20rpx 0;
		background-color: #fff;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		position: relative;

		.code {
			font-size: 32rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: #333;

			.status {
				font-size: 28rpx;
			}
		}

		.goodslist {
			width: 100%;
			margin-top: 20rpx;
			font-size: 28rpx;
			line-height: 40rpx;
			color: #333;
			display: flex;
			justify-content: space-between;

			.name {
				width: 180rpx;
				text-align: right;
				text-align: center;
			}
		}
	}

	.orderInfo {
		margin-top: 2rpx;
		background-color: #fff;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		font-size: 28rpx;

		.list {
			display: flex;
			justify-content: space-between;
			padding: 10rpx 0;
			align-items: center;

			.checkbox {
				display: flex;
				justify-content: space-between;
				align-items: center;
				gap: 20rpx;

				.typebox {
					line-height: 40rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

				}
			}

			.ipt {
				width: 70%;
				border: 2rpx solid #f7f7f7;
				font-size: 28rpx;
				padding: 10rpx 20rpx;
				border-radius: 10rpx;
			}
			.sum{
				font-size: 28rpx;
				border: 2rpx solid #f7f7f7;
				padding: 6rpx;
				border-radius: 6rpx;
				width: 510rpx;
				height: 40rpx;
			}
		}
	}

	.btnbox {
		width: 100%;
		margin-top: 30rpx;
		display: flex;
		justify-content: space-around;

		.btn {
			width: 200rpx;
			height: 60rpx;
			background-color: #fff;
			line-height: 60rpx;
			text-align: center;
			border-radius: 12rpx;
			font-size: 26rpx;
		}

		.next {
			background-color: #ffc400;
		}
	}
</style>